
$(function(){
    //发送ajax请求 请求数据
    var num=1;
    //请求所有音频数据
    $.ajax({
        type:'get',
        url:'http://api.heardtech.com/Get/Music?page='+num+"&token_key=c4ca4238a0b923820dcc509a6f75849b",
        dataType:"json",
        success: function (data) {
            //console.log('接受数据成功');
            //console.log(data);
            pageCount=data.data.data;
            var html=``;
            // console.log(result);
            for(var i=0;i<pageCount.length;i++){
                var obj=pageCount[i];
                html+=`
                     <li >
                        <img src="img/playing.gif" class="playImg h1" >
                        <img src="img/paused_Img_02.png" class="pauseImg h1" />
                        ${obj.title}
                        <i class="p${i}"></i>
                        <audio src="${obj.voiceurl}" id="${i}"></audio>
                        <!--进度条样式-->
                        <div id="progressWrap${i}">
                            <div id="playProgress${i}">
                            </div>
                        </div>
                    </li>
                `;
            }
            $('.ul_list').append(html);
        },
        error: function () {
            alert('请求失败！')
        }
    });

    $(".pullUpLabel").on('click', function () {
        num++;
        //console.log(num);
        if(pageCount.length<10){$('.pullUpLabel').html('没有更更多数据可以加载啦！')}
        $.ajax({
            type:'get',
            url:'http://api.heardtech.com/Get/Music?page='+num+"&token_key=c4ca4238a0b923820dcc509a6f75849b",
            dataType:"json",
            success: function (data) {
                //console.log('接受数据成功');
                //console.log(data);
                //var result=data.data.data;
                pageCount=pageCount.concat(data.data.data);
                var html=``;
                // console.log(result);
                for(var i=0;i<pageCount.length;i++){
                    var obj=pageCount[i];
                    html+=`
                     <li >
                        <img src="img/playing.gif" class="playImg h1" >
                        <img src="img/paused_Img_02.png" class="pauseImg h1" />
                        ${obj.title}
                        <i class="p${i}"></i>
                        <audio src="${obj.voiceurl}" id="${i}"></audio>
                        <!--进度条样式-->
                        <div id="progressWrap${i}">
                            <div id="playProgress${i}">
                            </div>
                        </div>
                    </li>
                `;
                }
                $('.ul_list').append(html);
            },
            error: function () {
                alert('请求失败！')
            }
        });
    })
});

